package com.sneakxy.cloudbase.platform.service;

import java.util.Map;

import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.cloud.openfeign.SpringQueryMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;

import com.sneakxy.cloudbase.platform.bean.dto.AccountDTO;
import com.sneakxy.cloudbase.platform.utils.web.DataGrid;
import com.sneakxy.cloudbase.platform.utils.web.PageSearch;
import com.sneakxy.cloudbase.platform.utils.web.Response;

@FeignClient(name="security-producer", path="/security/api/account")
public interface AccountClient {

	@PostMapping("one")
	public Response<AccountDTO> one(
			@RequestParam(name="accountId")
			String accountId);
	
	@PostMapping("account")
	public Response<AccountDTO> account(
			@RequestParam(name="principal")
			String principal,
			@RequestParam(name="host", required = false)
			String host);
	
	@PostMapping("multiple")
	public Response<AccountDTO[]> multiple(
			@RequestParam(name="accountIds")
			String[] accountIds);
	
	@PostMapping("datagrid")
	public Response<DataGrid<AccountDTO>> datagrid(@SpringQueryMap PageSearch<String> search);
	
	@PostMapping("datagridByRoleId")
	public Response<DataGrid<AccountDTO>> datagrid(
			@SpringQueryMap
			PageSearch<String> search,
			@RequestParam(name="roleId")
			String roleId);
	
	@PostMapping("add")
	public Response<AccountDTO> add(@SpringQueryMap AccountDTO account);
	
	@PostMapping("edit")
	public Response<AccountDTO> edit(@SpringQueryMap AccountDTO account);
	
	@PostMapping("validateAccountAdd")
	public Response<Boolean> validate(
			@RequestParam(name="account") String account, 
			@RequestParam(name="host", required = false) String host);
	
	@PostMapping("validateAccountEdit")
	public Response<Boolean> validate(
			@RequestParam(name="id")
			String id, 
			@RequestParam(name="account")
			String account,
			@RequestParam(name="host", required = false) String host);
	
	@PostMapping("remove")
	public Response<Object> remove(@RequestParam(name="ids") String[] ids);
	
	@PostMapping("roleData")
	public Response<Map<String, Object>> roleData(@RequestParam(name="id") String id);
	
	@PostMapping("role")
	public Response<String> role(
			@RequestParam(name="id")
			String id,
			@RequestParam(name="roleIds")
			String[] roleIds);
	
	@PostMapping("roles")
	public Response<String> roles(
			@RequestParam(name="id")
			String id,
			@RequestParam(name="roleIds")
			String[] roleIds);
	
	@PostMapping("rmroles")
	public Response<String> rmroles(
			@RequestParam(name="id")
			String id,
			@RequestParam(name="roleIds")
			String[] roleIds);
	
	@GetMapping("settings")
	public Response<Map<String, String>> settings(
				@RequestParam(name="accountId")
				String accountId);
	
	@GetMapping("single/setting")
	public Response<String> setting(
				@RequestParam(name="accountId")
				String accountId,
				@RequestParam(name="key")
				String key);
	
	@PostMapping("setting")
	public Response<Boolean> setting(
			@RequestParam(name="accountId")
			String accountId,
			@RequestParam(name="key")
			String key,
			@RequestParam(name="value", required=false)
			String value);
	
}
